package com.dic.common.base.service.impl;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dic.common.base.dao.IBaseDao;
import com.dic.common.base.service.IBaseService;

@Service
@Transactional
public class BaseServiceImpl implements IBaseService{

	@Autowired
	public IBaseDao baseDaoImpl;
	
	@Override
	public boolean save(Object entity) {
		return baseDaoImpl.save(entity);
	}

	@Override
	public boolean update(Object entity) {
		return baseDaoImpl.update(entity);
	}

	@Override
	public <T> T getEntityById(Class<T> objClass, String id) {
		return baseDaoImpl.getEntityById(objClass, id);
	}

	@Override
	public <T> void delete(Class<T> objClass, String ids) {
		String[] idz = ids.split(",");
		for (int i = 0; i < idz.length; i++) {
			this.baseDaoImpl.delete(this.getEntityById(objClass,idz[i]));
		}
	}

	@Override
	public void delete(Object entity) {
		this.baseDaoImpl.delete(entity);
	}

}
